home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6588 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: erich.triumf.ca!bennett
  2. From: bennett@erich.triumf.ca (P.Bennett)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: string and NULL :question
  5. Date: 17 Feb 1996 09:50 PST
  6. Organization: TRIUMF: Tri-University Meson Facility
  7. Distribution: world
  8. Message-ID: <17FEB199609501198@erich.triumf.ca>
  9. References: <zakrzews.824018783@pegasus.montclair.edu>
  10. NNTP-Posting-Host: ftp.triumf.ca
  11. News-Software: VAX/VMS VNEWS 1.50    
  12.  
  13. In article <zakrzews.824018783@pegasus.montclair.edu>, zakrzews@pegasus.montclair.edu (Tomas Zakrzewski) writes...
  14. >Hi   !
  15. >Is it save to use a string library and stdio library with strings that are
  16. >no terminated by NULL charater. If is not, which function may not work correctly
  17. >and what would happen with non termianded string if a function is applied to
  18. >that string.
  19.  
  20. to be (slightly) pedantic, NULL is not a character - it is a macro used to set
  21. pointers to a known invalid value. (this is probably not a very good
  22. description, but it's the best I can come up with at the moment...)
  23.  
  24. You mean the ASCII character nul (one L) which is represented by '\0'.
  25.  
  26. Almost all C string-handling functions _depend_ on strings being terminated
  27. with '\0', and will read beyond the intended end of a non-terminated string til
  28. they find a '\0'.
  29.  
  30. Exceptions are those fucntions starting with "strn", where you tell the
  31. function how many chars to look at.
  32.  
  33.  
  34. Peter Bennett VE7CEI                | Vessels shall be deemed to be in sight
  35. Internet: bennett@triumf.ca         | of one another only when one can be
  36. Packet: ve7cei@ve7kit.#vanc.bc.ca   | observed visually from the other
  37. TRIUMF, Vancouver, B.C., Canada     |                          ColRegs 3(k)
  38. GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
  39.  
  40.